package com.chuantou.yuba.util;

import android.content.Intent;
import android.net.Uri;
import android.os.Parcel;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.style.URLSpan;
import android.view.View;

import com.chuantou.yuba.ui.WebViewActivity;

public class NoUnderlineUrlSpan extends URLSpan {

	public NoUnderlineUrlSpan(Parcel src) {
		super(src);
	}

	public NoUnderlineUrlSpan(String url) {
		super(url);
	}

	@Override
	public void updateDrawState(TextPaint ds) {
		super.updateDrawState(ds);
		ds.setUnderlineText(false);
	}

	@Override
	public void onClick(View widget) {
		Intent intent = new Intent(widget.getContext(), WebViewActivity.class);
		Uri uri = Uri.parse(getURL());
		String scheme = uri.getScheme();
		String url = uri.toString();
		if (TextUtils.isEmpty(scheme)) {
			url = "http://" + url;
		}
		intent.putExtra(Constants.EXTRA_URL, url);
		widget.getContext().startActivity(intent);
	}
}
